package com.zx.dao.impl;

import com.zx.bean.Performance;
import com.zx.dao.PerformanceDao;
import com.zx.util.DruidUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class PerformanceDaoImpl implements PerformanceDao {
    public final String SQL_INSERT="insert into performance (TOTAL_AREA,TOTAL_BUIL_UP_AREA,LAND_AREA," +
            "QUALIFIED_PRODUCT_QUANTITY,OUTPUT_OF_MAJOR_POLLUTANS," +
            "EXHAUST_GAS_PRODUCTION,WASTE_WATER_PRODUCTION," +
            "CONSUMPTION_OF_MAJOR_RAW_MATERIALS,COMPREHENSIVE_UTILIZATION_OF_INDUSTRIAL_SOLID_WASTE," +
            "PRODUCTION_OF_INDESTRIAL_SOLID,WASTE_WATER_TREATMENT_RECYCLING_AMOUNT," +
            "AMOUNT_OF_PHYSICAL_ENERGY_CONSUMED,CARBON_DIOXIDE_EMISSIONS,YEAR,MOUNTH,COMPNAYNO," +
            "ZT,ZW,VD)" +
            "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    @Override
    public boolean insert(Performance performance) {
        Connection connection= DruidUtil.getConnection();
        PreparedStatement preparedStatement=null;
        try {
            preparedStatement=connection.prepareStatement(SQL_INSERT);
          //  preparedStatement.setInt(1,1);
            preparedStatement.setDouble(1,performance.getTatalArea());
            preparedStatement.setDouble(2,performance.getTatalBuilUpArea());
            preparedStatement.setDouble(3,performance.getLandArea());
            preparedStatement.setDouble(4,performance.getQualifiedProductQuantity());
            preparedStatement.setDouble(5,performance.getOutputOfMajorPollutans());
            preparedStatement.setDouble(6,performance.getExhaustGasProduction());
            preparedStatement.setDouble(7,performance.getWasteWaterProduction());
            preparedStatement.setDouble(8,performance.getConsumptionOfMajorRawMaterials());
            preparedStatement.setDouble(9,performance.getComprehensiveUtilizationOfIndustrialSolidWaste());
            preparedStatement.setDouble(10,performance.getProductionOfIndestrialSolid());
            preparedStatement.setDouble(11,performance.getWasteWaterTreatmentRecyclingAmount());
            preparedStatement.setDouble(12,performance.getAmountOfPhysicalEnergyConsumed());
            preparedStatement.setDouble(13,performance.getCarbonDioxideEmissions());
            preparedStatement.setString(14,performance.getYear());
            preparedStatement.setString(15,performance.getMounth());
            preparedStatement.setString(16,performance.getCompanyNo());
            preparedStatement.setDouble(17,performance.getZt());
            preparedStatement.setDouble(18,performance.getZw());
            preparedStatement.setDouble(19,performance.getVd());
            return preparedStatement.executeUpdate()>0?true:false;
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DruidUtil.close(connection,preparedStatement,null);
        }


        return false;
    }
}
/**
 *   //总建筑物面积
 *     private double tatalArea;
 *     //总构筑物面积
 *     private double tatalBuilUpArea;
 *     //工厂用地面积
 *     private double landArea;
 *     //合格产品总量
 *     private int qualifiedProductQuantity;
 *     //主要污染物产量
 *     private double outputOfMajorPollutans;
 *     //废气生产量
 *     private double exhaustGasProduction;
 *     //废水生产量
 *     private double wasteWaterProduction;
 *     //主要原材料消耗量
 *     private double consumptionOfMajorRawMaterials;
 *     //工业固体综合利用率
 *     private double comprehensiveUtilizationOfIndustrialSolidWaste;
 *     //工业固体废物生产量
 *     private double productionOfIndestrialSolid;
 *     //废水处理回用量
 *     private double wasteWaterTreatmentRecyclingAmount;
 *     //消耗能源实物量
 *     private double amountOfPhysicalEnergyConsumed;
 *     //二氧化碳排放量
 *     private double carbonDioxideEmissions;
 *     //年份
 *     private String year;
 *     //月份
 *     private  String mounth;
 */